package org.dromara.comm_lhz.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.dromara.comm_lhz.entity.AsGroupEntity;
import org.dromara.comm_lhz.mapper.AsGroupHMapper;
import org.dromara.comm_lhz.service.AsGroupHService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

/**
 * AsGroupHService的实现类，使用MyBatis Plus提供的ServiceImpl进行实现。
 */
@Service
public class AsGroupHHServiceImpl extends ServiceImpl<AsGroupHMapper, AsGroupEntity> implements AsGroupHService {

    // 注入AsGroupHMapper，用于操作数据库
    @Autowired
    private AsGroupHMapper asGroupHMapper;

    /**
     * 查询分组信息
     *
     * @return 分组信息的列表
     */
    @Override
    public IPage<AsGroupEntity> selGroupInfo(AsGroupEntity asGroupEntity, Pageable pageable) {
        // 设置分页参数
        Page<AsGroupEntity> pageParam = new Page<>(pageable.getPageNumber(), pageable.getPageSize());

        // 创建查询条件
        LambdaQueryWrapper<AsGroupEntity> queryWrapper = new LambdaQueryWrapper<>();
        if (asGroupEntity.getGroupName()!=null) {
            queryWrapper.like(AsGroupEntity::getGroupName, asGroupEntity.getGroupName());
        }
        // 执行分页查询
        return asGroupHMapper.selectPage(pageParam, queryWrapper);
    }

}
